$(function(){
	
	
	//轮播图
	//点击右键图片开始滚动
		var index = 0;
		var right = document.querySelector('.lb-right');
		var contents = document.querySelectorAll('.lb-content')
		right.onclick = function() {
			if(index == 4) {
				index = 0;
			} else {
				index++;
			}
			for(var i = 0; i < contents.length; i++) {
				contents[i].style.display = 'none';
			}
			contents[index].style.display = 'block';
			ball(index);
		}
		//点击左键图片向左滚动
		var left = document.querySelector('.lb-left');
		left.onclick = function() {
			if(index <= 0) {
				index = 4;
			} else {
				index--;
			}
			for(var i = 0; i < contents.length; i++) {
				contents[i].style.display = 'none';
			}
			contents[index].style.display = 'block';
			ball(index);
		}
		//创建计时器让大图滚动起来
		var timmer = setInterval(right.onclick, 1000);
		//当鼠标移入的时候大图滚动停止
		var wrap = document.querySelector('.lb-wrap');
		wrap.onmouseenter = function() {
			clearInterval(timmer);
		};
		//当鼠标移出时,开始大图滚动
		wrap.onmouseleave = function() {
			timmer = setInterval(right.onclick, 1000);
		};
		//添加下边的小圆函数
		function ball(a) {
			for(var j = 0; j < lis.length; j++) {
				if(j == a) {
					lis[j].style.backgroundColor = 'green';
					lis[j].style.opacity=1;
				} else {
					lis[j].style.backgroundColor = '#000';
					lis[j].style.opacity=0.2;
				}

			}
		}

		var lis = document.querySelectorAll('.lb-page li');
		lis[0].style.backgroundColor = 'green';
		for(var j = 0; j < lis.length; j++) {
			lis[j].onmouseenter = function() {
				for(var k=0;k<contents.length;k++){
					if(this==lis[k]){
						contents[k].style.display = 'block';
						index = k;
						ball(k);
					}else{
						contents[k].style.display = 'none';
					}
				}

			}
		}

	
})